<template>
  <div class="app-container">
    <el-col :span="12" :offset="6">
      <el-form style="margin-top:80px">
        <el-form-item label="审核开关：" prop="tag">
           <el-radio v-model="radio" label="2" @change='change'>开</el-radio>
           <el-radio v-model="radio" label="1" @change='change'>关</el-radio>
        </el-form-item>
      </el-form>
    </el-col>
  </div>
</template>

<script>

import { getList, toggleId } from '@/api/switch'

export default {
  data() {
    return {
      radio:'1'
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      getList().then(response => {
        this.radio = response.data
      })
    },
    change(radio){
      toggleId(radio).then(response => {
        const { code, message } = response
        if(code == 0){
          this.$notify({
            title: '成功',
            message: `审核开关${radio == '1' ? '已关闭' : '已打开'}`,
            type: 'success',
            duration: 2000
          })
        }else{
          this.$message(message)
        }
      })
    }
  }
}
</script>
